package com.ruoyi.flowable.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.flowable.domain.Flowpredict;
import com.ruoyi.flowable.service.IFlowpredictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 未完成的工作票Controller
 * 
 * @author ruoyi
 * @date 2022-08-01
 */
@RestController
@RequestMapping("/flowable/Flowpredict")
public class FlowpredictController extends BaseController
{
    @Autowired
    private IFlowpredictService flowpredictService;

    /**
     * 查询未完成的工作票列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:list')")
    @GetMapping("/list")
    public TableDataInfo list(Flowpredict flowpredict)
    {
        startPage();
        List<Flowpredict> list = flowpredictService.selectFlowpredictList(flowpredict);
        return getDataTable(list);
    }

    /**
     * 导出未完成的工作票列表
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:export')")
    @Log(title = "未完成的工作票", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Flowpredict flowpredict)
    {
        List<Flowpredict> list = flowpredictService.selectFlowpredictList(flowpredict);
        ExcelUtil<Flowpredict> util = new ExcelUtil<Flowpredict>(Flowpredict.class);
        return util.exportExcel(list, "Flowpredict");
    }

    /**
     * 获取未完成的工作票详细信息
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:query')")
    @GetMapping(value = "/{activityId}")
    public AjaxResult getInfo(@PathVariable("activityId") Long activityId)
    {
        return AjaxResult.success(flowpredictService.selectFlowpredictById(activityId));
    }

    /**
     * 新增未完成的工作票
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:add')")
    @Log(title = "未完成的工作票", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Flowpredict flowpredict)
    {
        return toAjax(flowpredictService.insertFlowpredict(flowpredict));
    }

    /**
     * 修改未完成的工作票
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:edit')")
    @Log(title = "未完成的工作票", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Flowpredict flowpredict)
    {
        return toAjax(flowpredictService.updateFlowpredict(flowpredict));
    }

    /**
     * 删除未完成的工作票
     */
    @PreAuthorize("@ss.hasPermi('flowable:Flowpredict:remove')")
    @Log(title = "未完成的工作票", businessType = BusinessType.DELETE)
	@DeleteMapping("/{activityIds}")
    public AjaxResult remove(@PathVariable Long[] activityIds)
    {
        return toAjax(flowpredictService.deleteFlowpredictByIds(activityIds));
    }
}
